﻿using System.ComponentModel;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using Dictionary.ERP;
using Extra.ERP;
using Common.Class;
using Common;
using System.Windows.Forms;
using System.Drawing;

namespace Dictionary
{
    public class xfmMachine : XtraForm
    {
        public delegate void AddedEventHander(object sender, DIC_MACHINE Item);

        public delegate void DeletedEventHandler(object sender, DIC_MACHINE Item, Common.Class.RowClickEventArgs e);

        public delegate void ItemSelectedEventHander(object sender, DIC_MACHINE item);

        public delegate void UpdatedEventHander(object sender, DIC_MACHINE Item);

        private readonly IContainer components;
        private bool _search;
        private xucMachine ucList;

        public xfmMachine()
        {
            components = null;
            _search = false;
            InitializeComponent();
            Init();
        }

        public xfmMachine(bool search)
        {
            components = null;
            _search = false;
            _search = search;
            InitializeComponent();
            Init();
        }

        public bool IsSearch
        {
            set { ucList.IsSearch = value; }
        }

        public event AddedEventHander Added;

        public event DeletedEventHandler Deleted;

        public event ItemSelectedEventHander ItemSelected;

        public event UpdatedEventHander Updated;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            SYS_LOG.Insert("Danh S\x00e1ch Thiết Bị", "Xem");
            ucList.CloseClick += new ButtonClickEventHander(ucList_CloseClick);
            ucList.Added += ucList_Added;
            ucList.Updated += ucList_Updated;
            ucList.Deleted += new xucMachine.DeletedEventHandler(ucList_Deleted);
            Text = (SysOption.Language == "EN") ? "Machine" : Text;
        }

        private void InitializeComponent()
        {
            var button = new MenuButton();
            var command = new ItemCommand();
            var command2 = new ItemCommand();
            var command3 = new ItemCommand();
            var command4 = new ItemCommand();
            var command5 = new ItemCommand();
            var command6 = new ItemCommand();
            var command7 = new ItemCommand();
            var command8 = new ItemCommand();
            var command9 = new ItemCommand();
            var command10 = new ItemCommand();
            var command11 = new ItemCommand();
            var command12 = new ItemCommand();
            var command13 = new ItemCommand();
            var command14 = new ItemCommand();
            var command15 = new ItemCommand();
            var command16 = new ItemCommand();
            var command17 = new ItemCommand();
            var command18 = new ItemCommand();
            var command19 = new ItemCommand();
            var command20 = new ItemCommand();
            var command21 = new ItemCommand();
            var command22 = new ItemCommand();
            var command23 = new ItemCommand();
            var command24 = new ItemCommand();
            var command25 = new ItemCommand();
            var command26 = new ItemCommand();
            var command27 = new ItemCommand();
            var command28 = new ItemCommand();
            var command29 = new ItemCommand();
            ucList = new xucMachine();
            base.SuspendLayout();
            ucList.Dock = DockStyle.Fill;
            ucList.IsClose = CloseOrNew.None;
            ucList.IsSearch = false;
            ucList.Location = new Point(0, 0);
            ucList.Name = "ucList";
            ucList.NotSave = false;
            command.Caption = "";
            command.Enable = false;
            command.Visibility = BarItemVisibility.Never;
            button.Add = command;
            command2.Caption = "";
            command2.Enable = false;
            command2.Visibility = BarItemVisibility.Never;
            button.Cancel = command2;
            command3.Caption = "";
            command3.Enable = false;
            command3.Visibility = BarItemVisibility.Never;
            button.Change = command3;
            command4.Caption = "";
            command4.Enable = false;
            command4.Visibility = BarItemVisibility.Never;
            button.Close = command4;
            command5.Caption = "";
            command5.Enable = false;
            command5.Visibility = BarItemVisibility.Never;
            button.Custom = command5;
            command6.Caption = "";
            command6.Enable = false;
            command6.Visibility = BarItemVisibility.Never;
            button.Delete = command6;
            command7.Caption = "";
            command7.Enable = false;
            command7.Visibility = BarItemVisibility.Never;
            button.Export = command7;
            command8.Caption = "";
            command8.Enable = false;
            command8.Visibility = BarItemVisibility.Never;
            button.Filter = command8;
            command9.Caption = "";
            command9.Enable = false;
            command9.Visibility = BarItemVisibility.Never;
            button.FilterCustomer = command9;
            command10.Caption = "";
            command10.Enable = false;
            command10.Visibility = BarItemVisibility.Never;
            button.FilterStock = command10;
            command11.Caption = "";
            command11.Enable = false;
            command11.Visibility = BarItemVisibility.Never;
            button.Find = command11;
            button.GClose = false;
            button.GCommand = false;
            button.GExport = false;
            command12.Caption = "";
            command12.Enable = false;
            command12.Visibility = BarItemVisibility.Never;
            button.Go = command12;
            button.GOption = false;
            button.GPrint = false;
            button.GRecords = false;
            button.GSearchBar = false;
            button.GSettings = false;
            button.GVaildation = false;
            command13.Caption = "";
            command13.Enable = false;
            command13.Visibility = BarItemVisibility.Never;
            button.Import = command13;
            command14.Caption = "";
            command14.Enable = false;
            command14.Visibility = BarItemVisibility.Never;
            button.Next = command14;
            command15.Caption = "";
            command15.Enable = false;
            command15.Visibility = BarItemVisibility.Never;
            button.PageSetup = command15;
            button.PHome = false;
            command16.Caption = "";
            command16.Enable = false;
            command16.Visibility = BarItemVisibility.Never;
            button.Previous = command16;
            command17.Caption = "";
            command17.Enable = false;
            command17.Visibility = BarItemVisibility.Never;
            button.Print = command17;
            command18.Caption = "";
            command18.Enable = false;
            command18.Visibility = BarItemVisibility.Never;
            button.PrintPreview = command18;
            button.PTool = false;
            command19.Caption = "";
            command19.Enable = false;
            command19.Visibility = BarItemVisibility.Never;
            button.Redo = command19;
            command20.Caption = "";
            command20.Enable = false;
            command20.Visibility = BarItemVisibility.Never;
            button.Refresh = command20;
            command21.Caption = "";
            command21.Enable = false;
            command21.Visibility = BarItemVisibility.Never;
            button.Save = command21;
            command22.Caption = "";
            command22.Enable = false;
            command22.Visibility = BarItemVisibility.Never;
            button.SaveAndClose = command22;
            command23.Caption = "";
            command23.Enable = false;
            command23.Visibility = BarItemVisibility.Never;
            button.SaveAndNew = command23;
            command24.Caption = "";
            command24.Enable = false;
            command24.Visibility = BarItemVisibility.Never;
            button.Search = command24;
            command25.Caption = "";
            command25.Enable = false;
            command25.Visibility = BarItemVisibility.Never;
            button.SearchText = command25;
            command26.Caption = "";
            command26.Enable = false;
            command26.Visibility = BarItemVisibility.Never;
            button.Task = command26;
            command27.Caption = "";
            command27.Enable = false;
            command27.Visibility = BarItemVisibility.Never;
            button.Undo = command27;
            command28.Caption = "";
            command28.Enable = false;
            command28.Visibility = BarItemVisibility.Never;
            button.Vaildate = command28;
            command29.Caption = "";
            command29.Enable = false;
            command29.Visibility = BarItemVisibility.Never;
            button.View = command29;
            ucList.RibbonBar = button;
            ucList.Size = new Size(0x2dd, 0x1c5);
            ucList.Status = Actions.None;
            ucList.TabIndex = 0;
            ucList.Title = "";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x2dd, 0x1c5);
            base.Controls.Add(ucList);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmMachine";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            Text = "Danh S\x00e1ch Thiết Bị";
            base.ResumeLayout(false);
        }

        public void RaiseAddedEventHander(DIC_MACHINE Item)
        {
            if (Added != null)
            {
                Added(this, Item);
            }
        }

        public void RaiseDeletedEventHander(DIC_MACHINE Item, RowClickEventArgs e)
        {
            if (Deleted != null)
            {
                Deleted(this, Item, e);
            }
        }

        private void RaiseItemSelectedEventHander(DIC_MACHINE item)
        {
            if (ItemSelected != null)
            {
                ItemSelected(this, item);
            }
        }

        public void RaiseUpdatedEventHander(DIC_MACHINE Item)
        {
            if (Updated != null)
            {
                Updated(this, Item);
            }
        }

        private void ucList_Added(object sender, DIC_MACHINE Item)
        {
            RaiseAddedEventHander(Item);
        }

        private void ucList_CloseClick(object sender)
        {
            base.Close();
        }

        private void ucList_Deleted(object sender, DIC_MACHINE Item, RowClickEventArgs e)
        {
            RaiseDeletedEventHander(Item, e);
        }

        private void ucList_Updated(object sender, DIC_MACHINE Item)
        {
            RaiseUpdatedEventHander(Item);
        }
    }
}